<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>职位修改</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css">
</head>
<body>
<%--layui-form  layui的表单样式，添加到form表单上--%>
<form class="layui-form"  method="post">
    <%--一个表单项--%>
    <input type="hidden" value="${role.id}" name="id">
    <div class="layui-form-item">
        <label class="layui-form-label">职位名称</label>
        <%--layui-input-inline 行内 block 占整行--%>
        <div class="layui-input-inline">
            <input type="text" name="name" value="${role.name}" placeholder="请输入职位名称" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">职位描述</label>
        <div class="layui-input-inline">
            <textarea type="text" name="description" class="layui-textarea">${role.description}</textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="update">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<%--引入js--%>
<script src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
<script>

    //layui引入特定模块的方式
    layui.use(['layer', 'form','jquery'], function () {
        var layer = layui.layer//layer 弹窗对象
            , form = layui.form;//表单对象
        var $=layui.$;
        //异步提交表单
        form.on("submit(update)",function (data) {

            $.post("${pageContext.request.contextPath}/role/update",data.field,function (result) {
                if(result.code==0){
                    layer.msg("修改成功！");
                    //刷新父框框口内容
                    parent.layui.table.reload("roleTable"
                        //     , {
                        //     page:{
                        //         curr:1
                        //     }
                        // }
                    )
                    //关闭弹出
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭
                }
            },"json");
            return false;//阻止默认表单提交
        })
    });
</script>
</body>
</html>
